import { Request } from "../request";

const getSigParameter = () => {};

// 获取时间
const getTime = () => {
  const date = new Date();
  const y = date.getFullYear();
  const m = date.getMonth() + 1;
  const d = date.getDate();
  return `${y}-${m}-${d}`;
};

import md5 from "crypto-js/md5";
const getTime2 = () => {
  const date = new Date();
  const Y = date.getFullYear();
  const M =
    date.getMonth() + 1 > 9 ? date.getMonth() + 1 : "0" + (date.getMonth() + 1);
  const D = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
  const H = date.getHours() > 9 ? date.getHours() : "0" + date.getHours();
  const m = date.getMinutes() > 9 ? date.getMinutes() : "0" + date.getMinutes();
  const s = date.getSeconds() > 9 ? date.getSeconds() : "0" + date.getSeconds();
  return `${Y}${M}${D}${H}${m}${s}`;
};
const getSig = () => {
  const a =
    "000000008a06c430018e653fa0fb00b2" +
    "866278f4bbf84d2b870eb69b5605a15d" +
    getTime2();
  const b = md5(a).toString();

  return b.toUpperCase();
};

export function testApi() {
  return Request.post(
    `http://10.51.102.41:8081/call/2013-12-26/Accounts/000000008a06c430018e653fa0fb00b2/Calls/LandingCalls/?sig=${getSig()}`,
    {
      appId: "000000008a06c430018e653fa12b00b4",
      to: "02827555555",
      displayNum: "13228331395",
    }
  );
}
